//
//  SetTableViewCell.m
//  gdemm
//
//  Created by 乔明超 on 16/9/23.
//  Copyright © 2016年 Goldencis. All rights reserved.
//

#import "SetTableViewCell.h"
#import "Masonry.h"
#import "Utils.h"
@implementation SetTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _imgView = [[UIImageView alloc]init];
        _titleLable = [[UILabel alloc]init];
        _titleLable.textColor = [Utils UIColorFromHex:0Xffffff];
        [self addSubview:_imgView];
        [self addSubview:_titleLable];
        _lineView = [[UIView alloc]init];
        if ([DeviceTypeJudge isPadDeviceType]) {
            [self setupIpadView];
        }else{
            [self setupIphoneView];
        }
    }
    
    return self;
}

- (void)setupIpadView{

    [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.height.mas_equalTo(20);
        make.centerY.equalTo(self);
        make.left.mas_equalTo(20);
    }];
    
    _titleLable.font = [UIFont systemFontOfSize:20];
    [_titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self);
        make.left.mas_equalTo(_imgView.mas_right).offset(30);
    }];
    [self addSubview:self.lineView];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];
}

-(void)setupIphoneView{
    if ([DeviceTypeJudge isPadDeviceType]) {
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.mas_equalTo(16);
            make.centerY.equalTo(self);
            make.left.mas_equalTo(10);
        }];
        _titleLable.font = [UIFont systemFontOfSize:16];
        [_titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.mas_equalTo(_imgView.mas_right).offset(26);
        }];
    }else{
        [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.mas_equalTo(17);
            make.centerY.equalTo(self);
            make.left.mas_equalTo(12);
        }];
        [_titleLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self);
            make.left.mas_equalTo(_imgView.mas_right).offset(22);
        }];
        _titleLable.font = [UIFont systemFontOfSize:15];
    }
  
  
    [self addSubview:self.lineView];
    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
        make.height.mas_equalTo(1);
    }];

}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
    if (selected) {
        self.backgroundColor = [Utils colorWithKey:@"leftCellBgColor"];
        [UIView animateWithDuration:1.0 animations:^{
            self.backgroundColor = [UIColor clearColor];
        }];
    }else{
        self.backgroundColor = [UIColor clearColor];
    }
}

@end
